package com.ie.controller;

import cn.hutool.core.lang.hash.CityHash;
import com.ie.common.http.Result;
import com.ie.common.http.ResultCodeEnum;
import com.ie.entity.Activity;
import com.ie.entity.Losspets;
import com.ie.service.ActivityService;
import com.ie.service.LosspetsService;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.java.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/system/activity")
public class ActivityController
{
    @Autowired
    private ActivityService activityService;

    @Autowired
    private LosspetsService losspetsService;

    //所有活动
    @GetMapping("/all")
    public List<Activity> getAllActivity()
    {
        return activityService.getAllActivity();
    }
    //编辑
    @PostMapping("/edit")
    public boolean editActivity(@RequestBody Activity activity)
    {
        System.err.println(activity);
        return activityService.editActivity(activity);
    }
    //删除
    @DeleteMapping("/delete")
    public boolean deleteActivity(@RequestParam("id") String id) {
        return activityService.deleteActivity(id);
    }

    /**
     * 获取获取
     *
     * @param name
     * @param type
     * @param city
     * @return
     */
    @GetMapping("/search")
    public Result getAllActivityByType(
            @RequestParam("name") String name,
            @RequestParam("type") String type,
            @RequestParam("city") String city
    ) {
        List activity = activityService.selectList(name, type, city);
        return Result.build(activity, ResultCodeEnum.SUCCESS);
    }




}
